package com.xucy.springboot.common.BalanceTree;

/**
 * @Author xucy
 * @Date 2019-04-18 10:02
 * @Description (平衡二叉树)二叉排序树
 **/

public class BinaryTree {

    public static void main(String[] args) {


        //生成二叉排序树
        Node root=new Node(8);
        root.addNode(new Node(9));
        root.addNode(new Node(6));
        root.addNode(new Node(7));
        root.addNode(new Node(5));
        root.addNode(new Node(4));

        Node root2=new Node(2);
        root2.addNode(new Node(1));
        root2.addNode(new Node(4));
        root2.addNode(new Node(3));
        root2.addNode(new Node(5));
        root2.addNode(new Node(6));
        Node.midSort(root);
        System.out.println(root.height());
        System.out.println(root.value);

        System.out.println("---------");
        System.out.println(root2.height());
        System.out.println(root2.value);
    }
}
